package com.atguigu.gulimall.order.feign.fallback;

import com.atguigu.common.exception.BizCodeEnum;
import com.atguigu.common.utils.R;
import com.atguigu.gulimall.order.feign.WareFeignService;
import com.atguigu.gulimall.order.vo.WareSkuLockVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @create: 2024/9/11
 * @author: gyhe10
 * @description:
 **/

@Slf4j
@Component
public class WareFeignServiceFallback implements WareFeignService {
    @Override
    public R getSkusHasStock(List<Long> skuIds) {
        log.error("远程调用 ware 服务批量查询商品库存信息失败，涉及商品 ID：{}", skuIds);
        return R.error(BizCodeEnum.CALL_OTHER_SERVICE_EXCEPTION.getCode(), "远程调用 ware 服务批量查询商品库存信息失败，涉及商品 ID：" + skuIds);
    }

    @Override
    public R getFare(Long addrId) {
        log.error("远程调用 ware 服务根据地址 ID 查询收货地址详情和运费信息失败，涉及地址 ID：{}", addrId);
        return R.error(BizCodeEnum.CALL_OTHER_SERVICE_EXCEPTION.getCode(), "远程调用 ware 服务根据地址 ID 查询收货地址详情和运费信息失败，涉及地址 ID：" + addrId);
    }

    @Override
    public R orderLockStock(WareSkuLockVo vo) {
        log.error("远程调用 ware 服务锁定商品库存失败，涉及订单编号：{}", vo.getOrderSn());
        return R.error(BizCodeEnum.CALL_OTHER_SERVICE_EXCEPTION.getCode(), "远程调用 ware 服务锁定商品库存失败，涉及订单编号：" + vo.getOrderSn());
    }
}
